import 'package:flutter/material.dart';

import 'dart:convert' show json;

class RegionRes {
  int code;
  String message;
  List<Item> result;

  RegionRes.fromParams({this.code, this.message, this.result});

  factory RegionRes(jsonStr) => jsonStr == null ? null : jsonStr is String ? new RegionRes.fromJson(json.decode(jsonStr)) : new RegionRes.fromJson(jsonStr);

  RegionRes.fromJson(jsonRes) {
     code = jsonRes['code'];
    message = jsonRes['message'];
    result = jsonRes['result'] == null ? null : [];

    for (var resultItem in result == null ? [] : jsonRes['result']){
      result.add(resultItem == null ? null : new Item.fromJson(resultItem));
    }
  }

  @override
  String toString() {
    return '{"code": $code,"message": ${message != null?'${json.encode(message)}':'null'},"result": $result}';
  }
}

class Item {

  String image;
  String passtime;
  String path;
  String title;

  Item.fromParams({this.image, this.passtime, this.path, this.title});

  Item.fromJson(jsonRes) {
    image = jsonRes['image'];
    passtime = jsonRes['passtime'];
    path = jsonRes['path'];
    title = jsonRes['title'];
  }

  @override
  String toString() {
    return '{"image": ${image != null?'${json.encode(image)}':'null'},"passtime": ${passtime != null?'${json.encode(passtime)}':'null'},"path": ${path != null?'${json.encode(path)}':'null'},"title": ${title != null?'${json.encode(title)}':'null'}}';
  }
}

